package fun._6742.enums;

import lombok.Getter;
import org.springframework.http.HttpStatus;
import fun._6742.exception.CustomException;

public enum AuthorizationTypeEnums {

    COSTUMER(0, "costumer"),
    SHOPKEEPER(1, "shopkeeper");

    @Getter
    private String name;
    @Getter
    private int code;

    private AuthorizationTypeEnums(int code, String message) {
        this.code = code;
        this.name = message;
    }

    public static AuthorizationTypeEnums getByCode(int code){
        for (AuthorizationTypeEnums value : values()) {
            if (value.getCode()==code) {
                return value;
            }
        }
        throw new CustomException(HttpStatus.NOT_FOUND,"unknown authorization type");
    }
}
